home *** CD-ROM | disk | FTP | other *** search
- /***************************************************************************
- *
- * Copyright (c) 1990-1993 The Santa Cruz Operation, Inc.
- *
- * All rights reserved. No part of this program or publication may be
- * reproduced, transmitted, transcribed, stored in a retrieval system,
- * or translated into any language or computer language, in any form or
- * by any means, electronic, mechanical, magnetic, optical, chemical,
- * biological, or otherwise, without the prior written permission of:
- *
- * The Santa Cruz Operation , Inc. (408) 425-7222
- * 400 Encinal St., Santa Cruz, California 95060 USA
- *
- **************************************************************************/
- /*
- *
- * SCCS Stuff
- *
- * @(#) disp_info.c 12.1 95/05/09 SCOINC
- *
- * S003, 25-May-93, rickra
- * Made the default to draw to the Pixmap.......
- *
- * S002, 01-Jan-93, rickra
- * Added support for seperate windows.
- *
- * S001, 30-Sep-92, rickra
- * Really Change hard coded color referneces to user configurable.
- *
- * S000, 30-Sep-92, rickra
- * Added copyright and modification history
- * Change hard coded color referneces to user configurable.
- *
- */
- /*+-------------------------------------------------------------------------
- disp_info.c - XSW display several types of fixed width fields
- wht@n4hgf.Mt-Park.GA.US
-
- Defined functions:
- disp_info_int(x,y,label,fmt,value)
- disp_info_long(x,y,label,fmt,value)
- disp_static_int(x,y,label,fmt,value)
- disp_static_long(x,y,label,fmt,value)
-
- --------------------------------------------------------------------------*/
- /*+:EDITS:*/
- /*:09-25-1990-05:11-wht@n4hgf-release heh-heh x0.22 preliminary */
- /*:09-20-1990-00:09-wht@n4hgf-scales, sysinfo/minfo, bootinfo working */
- /*:09-15-1990-14:47-wht-creation */
-
- #include <X11/Xlib.h>
- #include <X11/Xutil.h>
- #include <X11/Intrinsic.h>
- #include <X11/Shell.h>
- #include <Xm/Xm.h>
- #include <Xm/MainW.h>
- #include <Xm/DrawingA.h>
-
- #include "include/unixincs.h"
- #include "include/buttons.h"
- #include "include/xsw.h"
-
- extern int in_expose_callback;
- extern int in_set_display_mode;
-
-
-
-
- /*+-------------------------------------------------------------------------
- disp_info_long(window,display,gc,DrawAreaXYWH,x,y,label,fmt,value)
- --------------------------------------------------------------------------*/
- void
- disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, label, fmt, value)
- Window window;
- Display *display;
- GC gc;
- XWindowAttributes DrawAreaXYWH;
- Pixmap pixmap;
- register int x, y;
- char *label;
- char *fmt;
- long value;
- {
- register int fwidth = FWIDTH;
- int len = strlen (label);
- char s32[32];
- /*
- if (redrawing_entire_DrawArea)
- {
- */
- XSetForeground (display, gc, colorLabel.pixel);
- /*
- XDrawString (display, window, gc, x, y + FASCENT, label, len);
- */
- XDrawString (display, pixmap, gc, x, y + FASCENT, label, len);
- /*
- }
- */
- x += (len * fwidth);
- sprintf (s32, fmt, value);
- len = strlen (s32);
- /*
- XClearArea (display, window, x, y, fwidth * len, FHEIGHT, 0);
- */
- XSetForeground (display, gc, background);
- XFillRectangle (display, pixmap, gc, x, y, fwidth * len, FHEIGHT);
-
- XSetForeground (display, gc, colorNumeric.pixel);
- /*
- XDrawString (display, window, gc, x, y + FASCENT, s32, len);
- */
- XDrawString (display, pixmap, gc, x, y + FASCENT, s32, len);
-
- } /* end of disp_info_long */
-
- /*+-------------------------------------------------------------------------
- disp_info_int(window,display,gc,DrawAreaXYWH,x,y,label,fmt,value)
- --------------------------------------------------------------------------*/
- void
- disp_info_int (window, display, gc, DrawAreaXYWH, x, y, pixmap, label, fmt, value)
- Window window;
- Display *display;
- GC gc;
- XWindowAttributes DrawAreaXYWH;
- register int x, y;
- Pixmap pixmap;
- char *label;
- char *fmt;
- int value;
- {
- register int fwidth = FWIDTH;
- int len = strlen (label);
- char s32[32];
- /*
- if (redrawing_entire_DrawArea)
- {
- */
- XSetForeground (display, gc, colorLabel.pixel);
- /*
- XDrawString (display, window, gc, x, y + FASCENT, label, len);
- */
- XDrawString (display, pixmap, gc, x, y + FASCENT, label, len);
- /*
- }
- */
- x += (len * fwidth);
- sprintf (s32, fmt, value);
- len = strlen (s32);
- /*
- XClearArea (display, window, x, y, fwidth * len, FHEIGHT, 0);
- XSetForeground (display, gc, colorNumeric.pixel);
- XDrawString (display, window, gc, x, y + FASCENT, s32, len);
- */
- XSetForeground (display, gc, background);
- XFillRectangle (display, pixmap, gc, x, y, fwidth * len, FHEIGHT);
-
- XSetForeground (display, gc, colorNumeric.pixel);
- XDrawString (display, pixmap, gc, x, y + FASCENT, s32, len);
-
- } /* end of disp_info_int */
-
- /*+-------------------------------------------------------------------------
- disp_static_long(window,display,gc,DrawAreaXYWH,x,y,label,fmt,value)
- --------------------------------------------------------------------------*/
- void
- disp_static_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, label, fmt, value)
- Window window;
- Display *display;
- GC gc;
- XWindowAttributes DrawAreaXYWH;
- Pixmap pixmap;
- register int x, y;
- char *label;
- char *fmt;
- long value;
- {
- register int fwidth;
- int len;
- char s32[32];
- /*
- if (redrawing_entire_DrawArea)
- {
- */
- fwidth = FWIDTH;
- len = strlen (label);
- XSetForeground (display, gc, colorLabel.pixel);
- /*
- XDrawString (display, window, gc, x, y + FASCENT, label, len);
- */
- XDrawString (display, pixmap, gc, x, y + FASCENT, label, len);
- x += (len * fwidth);
- sprintf (s32, fmt, value);
- /*
- XDrawString (display, window, gc, x, y + FASCENT, s32, strlen (s32));
- */
- XDrawString (display, pixmap, gc, x, y + FASCENT, s32, strlen (s32));
- /*
- }
- */
-
- } /* end of disp_static_long */
-
- /*+-------------------------------------------------------------------------
- disp_static_int(window,display,gc,DrawAreaXYWH,x,y,label,fmt,value)
- --------------------------------------------------------------------------*/
- void
- disp_static_int (window, display, gc, DrawAreaXYWH, pixmap, x, y, label, fmt, value)
- Window window;
- Display *display;
- GC gc;
- XWindowAttributes DrawAreaXYWH;
- Pixmap pixmap;
- register int x, y;
- char *label;
- char *fmt;
- int value;
- {
- register int fwidth;
- int len;
- char s32[32];
-
- /*
- if (redrawing_entire_DrawArea)
- {
- */
- fwidth = FWIDTH;
- len = strlen (label);
- XSetForeground (display, gc, colorLabel.pixel);
- /*
- XDrawString (display, window, gc, x, y + FASCENT, label, len);
- */
- XDrawString (display, pixmap, gc, x, y + FASCENT, label, len);
- x += (len * fwidth);
- sprintf (s32, fmt, value);
- /*
- XDrawString (display, window, gc, x, y + FASCENT, s32, strlen (s32));
- */
- XDrawString (display, pixmap, gc, x, y + FASCENT, s32, strlen (s32));
- /*
- }
- */
- } /* end of disp_static_int */
-
- /*+-------------------------------------------------------------------------
- disp_info_text(window,display,gc,DrawAreaXYWH,x,y,pixel,textstr)
-
- returns length of string
- --------------------------------------------------------------------------*/
- disp_info_text (window, display, gc, DrawAreaXYWH, x, y, pixmap, pixel, textstr)
- Window window;
- Display *display;
- GC gc;
- XWindowAttributes DrawAreaXYWH;
- int x;
- int y;
- Pixmap pixmap;
- unsigned long pixel;
- char *textstr;
- {
- register len = strlen (textstr);
-
- /*
- * Draw onto the window...
- */
-
- /*
- XClearArea (display, window, x, y, FWIDTH * len, FHEIGHT, 0);
- XSetForeground (display, gc, pixel);
- XDrawString (display, window, gc, x, y + FASCENT, textstr, len);
- */
-
- /*
- * Update the pixmap also...
- */
-
- XSetForeground (display, gc, background);
- XFillRectangle (display, pixmap, gc, x, y, FWIDTH * len, FHEIGHT);
- XSetForeground (display, gc, pixel);
- XDrawString (display, pixmap, gc, x, y + FASCENT, textstr, len);
- return (len * FWIDTH);
- } /* end of disp_info_text */
-
- /*+-------------------------------------------------------------------------
- disp_text(window,display,gc,DrawAreaXYWH,x,y,pixel,textstr)
-
- returns length of string
- --------------------------------------------------------------------------*/
- disp_text (window, display, gc, DrawAreaXYWH, pixmap, x, y, pixel, textstr)
- Window window;
- Display *display;
- GC gc;
- XWindowAttributes DrawAreaXYWH;
- Pixmap pixmap;
- int x;
- int y;
- unsigned long pixel;
- char *textstr;
- {
- register len = strlen (textstr);
-
- /*
- if ((in_expose_callback) || (current_server -> font_change) ||
- (in_set_display_mode))
- {
- XClearArea (display, window, x, y, FWIDTH * len, FHEIGHT, 0);
- XSetForeground (display, gc, pixel);
- XDrawString (display, window, gc, x, y + FASCENT, textstr, len);
- */
- XSetForeground (display, gc, background);
- XFillRectangle (display, pixmap, gc, x, y, FWIDTH * len, FHEIGHT);
-
- XSetForeground (display, gc, pixel);
- XDrawString (display, pixmap, gc, x, y + FASCENT, textstr, len);
-
- return (len * FWIDTH);
- /*
- }
- */
- } /* end of disp_info_text */
-
- /*+-------------------------------------------------------------------------
- disp_long(window,display,gc,DrawAreaXYWH,x,y,pixel,value)
-
- returns length of string
- --------------------------------------------------------------------------*/
- void
- disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, fmt, pixel, value)
- Window window;
- Display *display;
- GC gc;
- XWindowAttributes DrawAreaXYWH;
- Pixmap pixmap;
-
- int x;
- int y;
- char *fmt;
- unsigned long pixel;
- long value;
- {
- int len;
- char s32[32];
-
- sprintf (s32, fmt, value);
- len = strlen (s32);
- /*
- XClearArea (display, window, x, y, FWIDTH * len, FHEIGHT, 0);
- XSetForeground (display, gc, pixel);
- XDrawString (display, window, gc, x, y + FASCENT, s32, len);
- */
- XSetForeground (display, gc, background);
- XFillRectangle (display, pixmap, gc, x, y, FWIDTH * len, FHEIGHT);
- XSetForeground (display, gc, pixel);
- XDrawString (display, pixmap, gc, x, y + FASCENT, s32, len);
-
-
- } /* end of disp_info_text */
-
- /*+-------------------------------------------------------------------------
- disp_float(window,display,gc,DrawAreaXYWH,x,y,pixel,value)
-
- returns length of string
- --------------------------------------------------------------------------*/
- void
- disp_float (window, display, gc, DrawAreaXYWH, pixmap, x, y, fmt, pixel, value)
- Window window;
- Display *display;
- GC gc;
- XWindowAttributes DrawAreaXYWH;
- Pixmap pixmap;
- int x;
- int y;
- char *fmt;
- unsigned long pixel;
- float value;
- {
- int len;
- char s32[32];
-
- sprintf (s32, fmt, value);
- len = strlen (s32);
- /*
- XClearArea (display, window, x, y, FWIDTH * len, FHEIGHT, 0);
- */
- XSetForeground (display, gc, background);
- XFillRectangle (display, pixmap, gc, x, y, FWIDTH * len, FHEIGHT);
-
- XSetForeground (display, gc, pixel);
- /*
- XDrawString (display, window, gc, x, y + FASCENT, s32, len);
- */
- XDrawString (display, pixmap, gc, x, y + FASCENT, s32, len);
-
- } /* end of disp_float */
-
-
- /* vi: set tabstop=4 shiftwidth=4: */
- /* end of disp_info.c */
-